//-----------------------------------------------------------------------------
// File: xtypes.h
//
// Desc: basic type for building microplatform.
//       build20070120
//
// Author: Silva Lam
//-----------------------------------------------------------------------------
#pragma once
#pragma warning(disable:4996)

#ifndef _XTYPES_H_
#define _XTYPES_H_

#define __STDCALL   __stdcall
#define __CDECL     __cdecl
#define CONST       const

#ifndef NULL
#define NULL    0
#endif

#ifndef FALSE
#define FALSE   0
#endif

#ifndef TRUE
#define TRUE    1
#endif

#ifndef INVALID_VALUE
#define INVALID_VALUE (0x80000000)
#endif

#define DBL_DIG         15                      /* # of decimal digits of precision */
#define DBL_EPSILON     2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
#define DBL_MANT_DIG    53                      /* # of bits in mantissa */
#define DBL_MAX         1.7976931348623158e+308 /* max value */
#define DBL_MAX_10_EXP  308                     /* max decimal exponent */
#define DBL_MAX_EXP     1024                    /* max binary exponent */
#define DBL_MIN         2.2250738585072014e-308 /* min positive value */
#define DBL_MIN_10_EXP  (-307)                  /* min decimal exponent */
#define DBL_MIN_EXP     (-1021)                 /* min binary exponent */
#define _DBL_RADIX      2                       /* exponent radix */
#define _DBL_ROUNDS     1                       /* addition rounding: near */

#define FLT_DIG         6                       /* # of decimal digits of precision */
#define FLT_EPSILON     1.192092896e-07F        /* smallest such that 1.0+FLT_EPSILON != 1.0 */
#define FLT_GUARD       0
#define FLT_MANT_DIG    24                      /* # of bits in mantissa */
#define FLT_MAX         3.402823466e+38F        /* max value */
#define FLT_MAX_10_EXP  38                      /* max decimal exponent */
#define FLT_MAX_EXP     128                     /* max binary exponent */
#define FLT_MIN         1.175494351e-38F        /* min positive value */
#define FLT_MIN_10_EXP  (-37)                   /* min decimal exponent */
#define FLT_MIN_EXP     (-125)                  /* min binary exponent */
#define FLT_NORMALIZE   0
#define FLT_RADIX       2                       /* exponent radix */
#define FLT_ROUNDS      1                       /* addition rounding: near */

//
//Atom types
//
typedef char					int8_t;
typedef short int				int16_t;
typedef long int				int32_t;

#if _MSC_VER<=1200
typedef __int64					int64_t;
#else
typedef long long int	        int64_t;
#endif

typedef unsigned char			uint8_t;
typedef unsigned short int		uint16_t;
typedef unsigned long int		uint32_t;

#if _MSC_VER<=1200
typedef unsigned __int64		uint64_t;
#else
typedef unsigned long long int	uint64_t;
#endif


typedef int						int_t;
typedef unsigned int			uint_t;

typedef float					fp32_t;
typedef double					fp64_t;
typedef long double				fp128_t;



//
//Basic types
//
typedef fp32_t			float_t;
typedef int_t			fixed_t;

typedef int8_t			char_t;
typedef int16_t			short_t;
typedef int32_t			long_t;
typedef int64_t			longlong_t;

typedef uint8_t			uchar_t;
typedef uint16_t		ushort_t;
typedef uint32_t		ulong_t;
typedef uint64_t		ulonglong_t;

typedef uint8_t			byte_t;
typedef uint16_t		word_t;
typedef uint32_t		dword_t;
typedef uint64_t		qword_t;

typedef int_t			bool_t;
typedef byte_t			*memptr_t;
typedef void			*wildptr_t;
typedef const char_t	*lpcstr_t;
typedef char_t			*lpstr_t;


//
//xLayer types
//
typedef int8_t			xInt8;
typedef int16_t			xInt16;
typedef int32_t			xInt32;
typedef int64_t			xInt64;

typedef uint8_t			xUInt8;
typedef uint16_t		xUInt16;
typedef uint32_t		xUInt32;
typedef uint64_t		xUInt64;

typedef int_t			xInt;
typedef uint_t			xUInt;
typedef fp32_t			xFloat;
typedef fp64_t			xDouble;


//
//Compatible types
//
typedef int_t			BOOL;
typedef fp32_t			FLOAT;
typedef fp64_t			DOUBLE;

typedef int_t			INT;
typedef uint_t			UINT;

typedef int8_t			CHAR;
typedef int16_t			SHORT;
typedef int32_t			LONG;
typedef int64_t			LONGLONG;

typedef uint8_t			UCHAR;
typedef uint16_t		USHORT;
typedef uint32_t		ULONG;
typedef uint64_t		ULONGLONG;

typedef uint8_t			BYTE;
typedef uint16_t		WORD;
typedef uint32_t		DWORD;
typedef uint64_t		QWORD;

typedef int64_t			INT64;
typedef uint64_t		UINT64;

typedef uint8_t			*LPBYTE;
typedef void			*LPVOID;



typedef uint32_t xResult;
#define XR_OK (0)
#define XR_FAIL (-1)
#define XR_SUCCESS(ret) ( ((xResult)ret) >= 0 )
#define XR_FAILED(ret) ( ((xResult)ret) < 0 )



#endif //_XBASETD_H_
